import request from '@/config/axios'
import { UpdateRolePermissionParams } from './types'

// 角色管理列表
export const getRoleListApi = (params: any) => {
  return request.post({ url: '/role/list/more', params })
}

// 新增角色
export const createRoleApi = (data: any) => {
  return request.post({ url: '/role/create', data })
}

// 删除角色
export const deleteRoleApi = (id: number | string) => {
  return request.post({ url: `/role/delete/${id}` })
}

// 编辑角色
export const updateRoleApi = (data: any) => {
  return request.post({ url: '/role/update', data })
}

// 获取角色列表
export const roleOptionsApi = () => {
  return request.get({ url: '/role/options' })
}

// 角色权限获取
export const rolePermissionsApi = (roleId: number | string) => {
  return request.get({ url: `/role/permissions?roleId=${roleId}` })
}

// 角色权限变更
export const rolePermissionsUpdateApi = (params: UpdateRolePermissionParams) => {
  return request.post({ url: '/role/permissions/update', params })
}
